//
//  ViewController.swift
//  WZApp
//
//  Created by evol on 2018/6/8.
//  Copyright © 2018年 evol. All rights reserved.
//

import UIKit
import SnapKit
import RxCocoa
import RxSwift
import HandyJSON
import SwiftyJSON
import Moya

class ViewController: UIViewController {
    
    let disposeBag = DisposeBag()   //rxswift回收
    
    let tabbarResponse = PublishSubject<(NSInteger, NSInteger)>()   //元祖第一个参数 012 表示0取消 1第一级 2第二级 第二个参数表示id
    
    var tabbar: ELTabbarTool!   //底部分类
    var searchButton: UIButton! //搜索按钮
    var settingButton: UIButton! //设置按钮
    var scrollView:ELTileScrollView!
    
    let locationManager = AMapLocationManager() // 定位
    var currentLocation = CLLocationCoordinate2D(latitude:0, longitude:0)
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // 初始化数据
        initDatas()
        //滚动式图
        setTileScrollView()
        //初始化设置按钮
        setSettingButton()
        //初始化底部分类
        setTabbar()
        //初始化搜索按钮
        setSearchButton()
        
        setUpLocation()
    }
    
    func initDatas() {
        _ = AppCommonData.share
    }
    
    func setSettingButton(){
        //设置
        settingButton = UIButton(type: .custom)
        settingButton.setImage(UIImage(named: "icon_setting"), for: .normal)
        view.addSubview(settingButton)
        settingButton.snp.makeConstraints { (make) in
            make.left.equalTo(15)
            make.top.equalTo(STATUSBAR_HEIGHT)
        }
        
        settingButton.rx.tap.subscribe(onNext: { [weak self] _ in
            let settingViewModel = ELSettingViewModel()
            let settingView = ELSettingView(settingViewModel)
            self?.view.addSubview(settingView)
            settingView.snp.makeConstraints({ (make) in
                make.edges.equalTo((self?.view)!)
            })
        }).disposed(by: disposeBag)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

